//
//  LFTMCAlertView.m
//  Pods
//
//  Created by Thomas Quan on 2017/5/23.
//
//

#import "LFTMCAlertView.h"
#import "NTESGlobalMacro.h"

@interface LFTMCAlertView()

@property (nonatomic, strong) UILabel *label;

@end

@implementation LFTMCAlertView

- (instancetype)initWithAlertMsg:(NSString *)alertMsg
{
    self = [super init];
    if (self) {
        CGFloat screenWidth  = [UIScreen mainScreen].bounds.size.width;
        CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
        
        CGFloat timerWidth = 145;
        CGFloat timerHeight = 35;
        
        CGFloat x = screenWidth / 2;
        CGFloat y = 100.f;
        self.center = CGPointMake(x, y);
        
        self.bounds = CGRectMake(0, 0, timerWidth, timerHeight);
        
        [self setBackgroundColor:[UIColor whiteColor]];
        
        self.layer.cornerRadius = 15;
        self.layer.shadowOpacity = 0.8f;
        self.layer.shadowColor = [UIColor lightGrayColor].CGColor;
        self.layer.shadowOffset = CGSizeMake(2,2);
        self.layer.shadowRadius = 2;
        
        _label = [[UILabel alloc] initWithFrame:CGRectZero];
        [self addSubview:_label];
        
        _label.text = alertMsg;
        _label.textColor = UIColorFromRGB(0x97CC00);
        _label.textAlignment = NSTextAlignmentCenter;
        _label.font = [UIFont systemFontOfSize:14];
        
        [_label sizeToFit];
        
        _label.center = CGPointMake(timerWidth/2, timerHeight/2);
        _label.bounds = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
    
    }
    return self;
}

- (void)show {
    [UIView animateWithDuration:1.5 animations:^{
        
    } completion:^(BOOL finished) {
       [UIView animateWithDuration:0.5 animations:^{
           [self setHidden:YES];
       } completion:^(BOOL finished) {
           [self removeFromSuperview];
       }];
    }];
}


@end
